﻿using MaterialDesignThemes.Wpf;

namespace PLCS.Domain.Menus;

public class Menu : BaseEntity
{
    [Description("标题")]
    public string Title { get; set; }

    /// <summary>
    /// 视图名称
    /// </summary>
    [Description("视图名称")]
    public string? ViewName { get; set; }

    /// <summary>
    /// 图标
    /// </summary>
    [Description("图标")]
    public PackIconKind Icon { get; set; }

    /// <summary>
    /// 是否显示图标（一般二级菜单不显示）
    /// </summary>
    [Description("是否显示图标")]
    public int IsIcon { get; set; }

    /// <summary>
    /// 子元素
    /// </summary>
    [Description("子元素")]
    public List<Menu>? Children { get; set; }

    /// <summary>
    /// 父元素
    /// </summary>
    [Description("父元素")]
    public Menu? Parent { get; set; }

    public Guid? ParentId { get; set; }

    public Menu()
    {
    }

    /// <summary>
    /// 一级菜单初始化
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="icon">图标</param>
    public Menu(string title, PackIconKind icon)
    {
        Title = title;
        Icon = icon;
        CreationTime = DateTime.Now;
    }

    /// <summary>
    /// 二级菜单初始化
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="viewName">视图名称</param>
    public Menu(string title, string viewName, Guid parentId)
    {
        Title = title;
        ViewName = viewName;
        ParentId = parentId;
        Icon = PackIconKind.Abacus;
        IsIcon = 1;
        CreationTime = DateTime.Now;
    }
}